<?php

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

namespace app\wlgzh\controller;

use cmf\controller\HomeBaseController;
use app\portal\model\UserModel;
/**
 * Description of SijiController
 *
 * @author PVer
 */
class SijiController extends HomeBaseController {

//司机列表
    public function yhgl() {
        $user = cmf_get_current_user();
        $map = array();
        // $map["logistics"] = $user["id"];
        $map["a.user_category"] = 1;
        $map["a.user_type"] = 4;
        $list = db('user a')->join(array(array('dk_logistics b', 'a.logistics=b.Id', 'LEFT')
                ))
                ->field(' a.user_nickname,a.mobile,a.id,a.create_time,a.dk_status,b.LogisticsName')
                ->where($map)
                ->paginate();
        $this->assign('list', $list);
        return $this->fetch();
    }

//司机认证信息
    public function sfrz() {
        $data = $this->request->get();
        $logModel = new UserModel();
        $loglist = $logModel->where("user_category=2")->select();
        $this->assign('logistics', $loglist);
        $id = input('id');
        $map = array();
        $map['a.user_category'] = 1;
        $map['a.id'] = $id;
        $info = db('user a ')->join(array(array('dk_driverrecord b', 'a.id=b.UserId', 'LEFT')
                    , array('dk_user c', 'a.logistics=c.id', 'LEFT')
                    , array('dk_authrecord d', 'a.id=d.UserId', 'LEFT')
                    , array('dk_driverrecord e', 'a.id=e.UserId', 'LEFT')
                ))
                ->field(' a.user_nickname,a.avatar,a.birthday,a.create_time,a.id,a.logistics,a.mobile,a.number,a.dk_status,(select count(*) from dk_driver_loan where DriverId=a.id and Status in (3,4)) isDaikuan,a.user_level,a.can_loan,a.can_loan_amount,d.Img1,d.Img2,d.Img3,d.Img4,e.Img1 Img5,e.Img2 Img6,e.Img3 Img7,e.Img4 Img8,c.user_nickname LogisticsName')
                ->where($map)
                ->find();
        $this->assign('info', $info);
        $this->assign('logistics', $loglist);
        return $this->fetch();
    }

}
